<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      #pic {
        position: fixed;
      }
    </style>
</head>
<body>
    <img src="images/tianshi.gif" alt="" id="pic">
    <script>
    // 获取元素
    var pic = document.getElementById("pic");
    // 图片的位置跟随鼠标移动,
    // 鼠标移动时,鼠标距离浏览器窗口的尺寸就是图片位置
    document.onmousemove= function(e){
        e = e || window.event;
        pic.style.left = e.clientX + "px";
        pic.style.top = e.clientY + "px";
    }


    </script>
</body>
</html>